<?php !defined("IN_SYSTEM") && exit("ACCESS DENY");?>
<?php include template('header');?>
<div class="wmenu"><ul><li><a href="{BASE_URL}">首页</a> › </li><li><a href="{url list.php?dest=$store[dest]}" target="_blank">{$dest[$store['dest']]}</a> › </li><li><a href="{url list.php?dest=$store[dest]&region=$store[region]}" target="_blank">{$region[$store['dest']][$store['region']]}</a> › </li><li><a href="{url list.php?type=$store[cid]}" target="_blank">{$cates[$store['cid']]['catename']}</a> › </li> <li>{$store['shopname']}</li></ul></div>
	
<div class="wrap">
	<div class="wl">
		<div class="winfo">
		<h1><a href="{url store.php?id=$id}">{$store['shopname']}</a></h1>
		<div class="wtel">
		外卖电话: {$store['tel']}
		</div>
		<div class="wcon">
		{$store['minnum']}份起送，起送价{$store['minprice']}元，外送费用{$store['extprice']}元
		</div>
		</div>
		<div class="uc_tab">
			<ul><li><span><a href="{url store.php?id=$id}"{if !$action} class="on"{/if}>在线菜单</span></a></li>
				<li><span><a href="{url store.php?id=$id&a=review}"{if $action=='review'} class="on"{/if}>热门点评</a></span></li>
				<li><span><a href="{url store.php?id=$id&a=feedback}"{if $action=='feedback'} class="on"{/if}>用户留言</a></span></li>
				<li><span><a href="{url store.php?id=$id&a=offer}"{if $action=='offer'} class="on"{/if}>优惠信息</a></span></li>
				<li><span><a href="{url store.php?id=$id&a=map}"{if $action=='map'} class="on"{/if}>商家地图</a></span></li>
			</ul>
		</div>
		{if !$action}
		<div >
			<ul class="wgul">
			{loop $shopcates $cate}
			<li><a href="{url store.php?id=$id&c=$cate[cid]}"><span>{$cate['catename']}</span></a></li>
			{/loop}
			</ul>
		</div>
		<div>
		{loop $goods $k $v}
		{if !empty($v)}
		<div class="wgdiv">
		<h3>{$shopcates[$k]['catename']}</h3>
		{loop $v $good}
		<dl class="wgood">
		<dt>{$good['title']}</dt>
		<dd>{$good['price']}元</dd>
		{if $good['status']<1}
		<dd>已售完</dd>
		{else}
		<dd><a href="javascript:;" onclick="return crease({$good['pid']},2);" class="wcart">点一份</a></dd>
		{/if}
		</dl>
		{/loop}
		</div>
		
		{/if}
		{/loop}
		</div>
		{/if}
		
		{if $action=='feedback'}
		
		<?php !defined("IN_SYSTEM") && exit("ACCESS DENY");?>

					<div class="comments">
						<ol id="comment_list">
							{loop $comments $comment}
							{if $comment['status']< 1 || ($_G['uid'] > 0 && $comment['uid'] != $_G['uid'])}
							{else}
							{php $i++;}
								<li id="comment-{$comment['cid']}">
									<div class="comment_title">
										<a name="comment-{$comment['cid']}">{$i}.</a><strong>{$comment['username']}</strong>
										</div>
									<div class="comment_content">
									{$comment['content']}
									<p>
									<span class="comment_time">{echo gdate('Y-m-d H:i',$comment['dateline'])}  {if ican('reply_comment')}
										<a href="#post_comment" onclick="reply_comment({$comment['cid']});">回复</a>
										{/if}</span>
									</p>
									{loop $comment['subcomment'] $subcomments}
									<div class="replay"><div class="reply_title"><strong>{$comment['username']}</strong>   <span class="reply_time">{echo gdate('Y-m-d H:i',$comment['dateline'])}</span> </div>{$subcomments['content']}</div>
									{/loop}
									</div>
								</li>
								{/if}
							{/loop}
						</ol>	
					<a name="comments"></a>
						{if ican('post_comment')>0}
						<div id="comment-0">
						<div class="post_comment" >

						<a name="post_comment"></a>
						<form name="post_comment" id="post_comment" method="post" action="{url ajax.php?f=comment&a=add}" onsubmit="return ajax_post_comment()">
						<input type="hidden" name="aid" id="aid" value="{$id}" />
						<input type="hidden" name="shopid" id="shopid" value="{$id}" />
						<input type="hidden" name="pid" id="pid" value="0" />
						<input type="hidden" name="type" id="type" value="1" />

							<h3 id="post-comment-title"></h3>

							{if ( $_G['uid'] >0 )}
							<input type="hidden" name="isuser" id="isuser" value="1" />
							<p>您当前使用帐号 <strong>{$_G['username']}</strong></p>
							{else}

							<p><input type="text" name="username" id="username" class="input" size="30" /> <label id="tip_username" for="username">名称</label></p>
							<p><input type="text" name="email" id="email" class="input" size="30" /> <label id="tip_email" for="email">邮箱 (不公开)</label></p>
							{/if}
							<p>
							<textarea name="content" id="content" class="input" rows="3" cols="50"></textarea>
							<label id="tip_content" for="content"></label>
							</p>
							<p><input type="submit" id="submit" value="{lang submit_comment}" />
							<input type="checkbox" class="checkbox" name="hide" id="hide" value="1" /> <label for="hide">隐藏(仅管理员可见)</label>
							</p>
						</form>
						</div>
						</div>
						{/if}
					</div>
		
		
		{/if}
		
		
	</div>
	<div class="wr">
		<dl class="winfo">
		<dt>餐厅基本信息 </dt>
		<dd><strong>外卖时间:</strong>{$store['opentime']}-{$store['closetime']}</dd>
		{if $store['description']}<dd><strong>餐厅描述:</strong>{$store['description']}</dd>{/if}
		{if $store['tedian']}<dd><strong>餐厅特点:</strong>{$store['tedian']}</dd>{/if}
		{if $store['chengnuo']}<dd><strong>餐厅承诺:</strong>{$store['chengnuo']}</dd>{/if}
		{if $store['addr1']}<dd><strong>餐厅地址:</strong>{$store['addr1']}</dd>{/if}
		{if $store['addr2']}<dd><strong>公交线路:</strong>{$store['addr2']}</dd>{/if}
		</dl>
		
		
		<div class="cart" {if count($carts)<1}style="display:none;"{/if}>
		<h2>点菜单</h2>
		<div class="catitle"><span class="cart1">菜名</span><span class="cart2">数量</span><span class="cart3">价格</span></div>
		<div><ul id="caul">
		{loop $carts $cart}
		<li class="cali" id="cali{$cart['pid']}"><span class="cart1">{$cart['title']}</span><span class="cart2"><a href="javascript:;" onclick="crease({$cart['pid']},0)">-</a><font id="qty{$cart['pid']}">{$cart['qty']}</font><a href="javascript:;" onclick="crease({$cart['pid']},1)">+</a></span><span class="cart3"><font id="price{$cart['pid']}">{echo price($cart['price']*$cart['qty']);}</font></span><span class="cart4" onclick="crease({$cart['pid']},3)" title="删除">x</span></li>
		{php $total+=$cart['qty'] * $cart['price'];}
		{/loop}
		{php $total+=$store['extprice'];}
		</ul>
		</div>
		<div id="catdiv">{if $store['extprice']>0}外送费{$store['extprice']}元，{/if}合计 <span id="catotal" title="包含外送费{$store['extprice']}元">{echo price($total);}</span> 元 </div>
		<div style="text-align:right;margin-top:15px;"><a href="javascript:;" onclick="checkout();return false;"><input type="button" class="button" value="下单"/></a></div>
		
		<div class="checkout">
		<form action="{url index.php?m=cart&f=checkout}" id="cart" method="post" name="cart">
		<input type="hidden" name="shopid" value="{$id}"/>
		<div ><label>联系电话:</label><input type="text" class="input" name="phone" size="45"/></div>
		<div ><label>送餐地址:</label><input type="text" class="input" name="address" size="45" /></div>
		<div><label>送餐时间:</label><select id="deliver_time" name="deliver_time"><option selected="selected" value="">尽快送出</option>
<option value="22:45:00">22:45:00</option>
<option value="23:00:00">23:00:00</option>
<option value="23:15:00">23:15:00</option>
</select></div>

	<div class="clear">
      外送备注(选填):
<div id="cartextra">
    <span onclick="cartextra(this)">么零钱</span>
    <span onclick="cartextra(this)">不要葱姜蒜</span>
    <span onclick="cartextra(this)">不吃辣</span>
    <span onclick="cartextra(this)">辣一点</span>
    <span onclick="cartextra(this)">多加米</span>
    <span onclick="cartextra(this)">囧</span>
    <span onclick="cartextra(this)">谢谢:)</span>
</div>
<div class="text">
    <textarea tabindex="5" name="note" id="extra"  cols="54"></textarea>
    <div style="margin-top:10px;">
      <button class="button" type="submit" id="checkout_btn">下单</button>
    </div>
</div>
<div class="clear"></div>
    </div>
		</form>
		</div>
		<script>
		function cartextra(obj){
			$(obj).attr('onclick','dcartextra(this)');
			$('#extra').append(' '+$(obj).html());
		}
		function dcartextra(obj){
			$(obj).attr('onclick','cartextra(this)');
			var a=$('#extra').html();
			$('#extra').html(a.replace(' '+$(obj).html(),''));
		}
		function crease(id,t){
			if(t==1){
				var a='increase';
			}else if(t==2){
				var a='add';
			}else if(t==3){
				var a='clear';
			}else{
				var a='decrease';
			}
			$.getJSON("index.php?m=cart&f="+a+"&id="+id+'&tm='+Math.random(),'',function(data){
				if(data.s==true){
					if(t==2){
						$('#cali'+id).remove();
						$('#caul').append('<li class="caul" id="cali'+id+'"><span class="cart1">'+data.h+'</span><span class="cart2"><a href="javascript:;" onclick="crease('+id+',0)">-</a><font id="qty'+id+'">'+data.q+'</font><a href="javascript:;" onclick="crease('+id+',1)">+</a></span><span class="cart3"><font id="price'+id+'">'+money(data.p)+'</font></span><span class="cart4" onclick="crease('+id+',3)" title="删除">x</span></li>');
						$('.cart').show();
					}else if(t==3){
						if(data.t==0){
							$('#caul').html('');
							$('.cart').hide();
							//$('#catdiv').remove();
							return ;
						}else{
							$('#cali'+id).remove();
						}	
					}else{
					$('#qty'+id).html(data.q);
					$('#price'+id).html(money(data.p));
					}
					$('#catotal').html(money(data.t));
				}else{
				}
				});
		}
		function checkout(u){
			//check 
			$.getJSON('index.php?m=cart&f=ajaxcheck&id={$id}&tm='+Math.random(),'',function(data){
				if(data.s==false){
					alert(data.e);
				}else{
					var content = $('.checkout').html();
					$('.checkout').html('');
					var edit = artDialog({
					    title: '确认下单',
					    lock: true,
					    fixed: true, //C=G.DW
					    width:500,
					    padding:'0 0 0 15px',
					    cssname:'uc_editfrind',
					    content: content,
					    closeFn: function () {
					    	$('.checkout').html(content);
					    }
					});
				}
			});
			return false;
		}
		</script>
		
		</div>
	</div>
</div>



<?php include template('footer')?>